// MainDlg.h : interface of the CMainDlg class
//
/////////////////////////////////////////////////////////////////////////////

#pragma once

#include "BrowserDlg.h"
#include "NetAPI.h"
#include "encode.h"

extern HWND g_hWndParent;


class CLoginDlg : public CDialogImpl<CLoginDlg>, 
				  public CWinDataExchange<CLoginDlg>,
				  public CUpdateUI<CLoginDlg>,
				  public CMessageFilter, 
				  public CIdleHandler
{
public:
	enum { IDD = IDD_LOGINDLG };

	virtual BOOL PreTranslateMessage(MSG* pMsg);

	virtual BOOL OnIdle();

	BEGIN_UPDATE_UI_MAP(CLoginDlg)
	END_UPDATE_UI_MAP()


	BEGIN_MSG_MAP(CLoginDlg)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
		MESSAGE_HANDLER(WM_CLOSE, OnClose)
		COMMAND_ID_HANDLER(IDLOGIN, OnLogin)
		COMMAND_ID_HANDLER(IDREG, OnRegister)
	END_MSG_MAP()

    BEGIN_DDX_MAP(CLoginDlg)
        DDX_TEXT(IDC_USER, m_sUserName)
        DDX_TEXT(IDC_PASS, m_sPassWord)
		DDX_CONTROL(IDC_LINK, m_lnkRegister)
		DDX_CONTROL(IDC_LINK2, m_lnkFindPass)
    END_DDX_MAP()

	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnLogin(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnRegister(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);

private:
	void CloseDialog(int nVal);

protected:
	CString m_sUserName;
	CString m_sPassWord;
	CHyperLink m_lnkRegister;
	CHyperLink m_lnkFindPass;
	CBrowserDlg* m_pdlg;
};
